~ chicken-core (master) /manual/Module (chicken process-context)


  1[[tags: manual]]
  2[[toc:]]
  3
  4== Module (chicken process-context)
  5
  6This module provides access to the current process context.
  7
  8* New in CHICKEN 5.4.0: Errors caused by underlying C calls that
  9  change errno will produce a condition object with an {{errno}}
 10  property, which can be accessed with
 11  {{(get-condition-property <the-condition-object> 'exn 'errno)}}.
 12
 13=== Information about the program's invocation
 14
 15==== argc+argv
 16
 17<procedure>(argc+argv)</procedure>
 18
 19Returns two values: an integer and a foreign-pointer object
 20representing the {{argc}} and {{argv}} arguments passed to the current
 21process.  See also {{argv}} below.
 22
 23==== argv
 24
 25<procedure>(argv)</procedure>
 26
 27Return a list of all supplied command-line arguments. The first item in
 28the list is a string containing the name of the executing program. The
 29other items are the arguments passed to the application. It depends on
 30the host-shell whether arguments are expanded ('globbed') or not.
 31
 32NOTE: This is the "raw" unprocessed argument list, including runtime
 33options (starting with {{-:}}) which are consumed by the runtime
 34library.
 35
 36==== command-line-arguments
 37
 38<parameter>(command-line-arguments)</parameter>
 39
 40Contains the list of arguments passed to this program.
 41
 42This ''excludes'' the name of the program, as well as any runtime
 43options (options starting with {{-:}}) up until the first empty
 44runtime option (just {{"-:"}}) or non-runtime option, whichever
 45comes first.
 46
 47In other words, this method returns every option ''after'' the first
 48list of unbroken runtime options, which are all skipped.  If an empty
 49runtime option is present, that is the last of this list of unbroken
 50runtime options and everything after it is returned by this method.
 51If a non-runtime option is present, that also breaks up the runtime
 52options and this method returns that and every following option.
 53
 54==== executable-pathname
 55
 56<procedure>(executable-pathname)</procedure>
 57
 58Returns a full pathname of the currently-running executable, or {{#f}}
 59if it couldn't be determined. When evaluating code in the interpreter,
 60this will be a path to {{csi}}.
 61
 62==== program-name
 63
 64<parameter>(program-name)</parameter>
 65
 66The name of the currently executing program. This is equivalent to
 67{{(car (argv))}} for compiled programs or the filename following the
 68{{-script}} option in interpreted scripts.
 69
 70
 71=== Access to environment variables
 72
 73==== get-environment-variables
 74
 75<procedure>(get-environment-variables)</procedure>
 76
 77Returns a association list of the environment variables and their
 78current values (see also [[http://srfi.schemers.org/srfi-98/|SRFI-98]]).
 79
 80==== get-environment-variable
 81
 82<procedure>(get-environment-variable STRING)</procedure><br>
 83
 84Returns the value of the environment variable {{STRING}} or
 85{{#f}} if that variable is not defined. See also [[http://srfi.schemers.org/srfi-98/|SRFI-98]].
 86
 87==== set-environment-variable!
 88
 89<procedure>(set-environment-variable! VARIABLE VALUE)</procedure>
 90
 91Sets the environment variable named {{VARIABLE}} to
 92{{VALUE}}. Both arguments should be strings. If the variable is
 93not defined in the environment, a new definition is created.
 94
 95==== unset-environment-variable!
 96
 97<procedure>(unset-environment-variable! VARIABLE)</procedure>
 98
 99Removes the definition of the environment variable {{VARIABLE}} from
100the environment of the current process. If the variable is not defined,
101nothing happens.
102
103
104=== Process filesystem context
105
106==== change-directory
107
108<procedure>(change-directory NAME)</procedure>
109<procedure>(set! (current-directory) NAME)</procedure>
110
111Changes the current working directory to {{NAME}}.
112
113==== current-directory
114
115<procedure>(current-directory)</procedure>
116
117Returns the name of the current working directory.
118
119---
120Previous: [[Module (chicken process signal)]]
121
122Next: [[Module (chicken process-context posix)]]
Trap